package collectionexercise;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOpenDemo {
    public static void main(String[] args) {
        Collection<String> c1 = new ArrayList<>();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println("c1:"+c1);

        Collection<String> c2 = new ArrayList<>();
        c2.add("android");
        c2.add("ios");
        c2.add("java");
        System.out.println("c2:"+c2);

        c1.addAll(c2);
        System.out.println("c1:"+c1);

        Collection<String> c3 = new ArrayList<>();
        c3.add("c++");
        c3.add("android");
        c3.add("php");
        System.out.println("c3:"+c3);

        System.out.println(c1.contains(c3));//f

        c1.retainAll(c3);
        System.out.println("c1:"+c1);

        Collection<String> c4 = new ArrayList<>();
        c4.add("c++");
        c4.add("android");
        c4.add("php");
        System.out.println("c4:"+c4);

        c2.removeAll(c4);
        System.out.println("c2:"+c2);
    }
}
